/*
 ============================================================================
 Name		: MoboJson.cpp
 Author	  : 
 Copyright   : Your copyright notice
 Description : CMoboJson DLL source
 ============================================================================
 */

//  Include Files  

#include "MoboJson.h"	// CMoboJson
#include "MoboJson.pan"	  	// panic codes

//  Member Functions

EXPORT_C CMoboJson* CMoboJson::NewLC()
	{
	CMoboJson* self = new (ELeave) CMoboJson;
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

EXPORT_C CMoboJson* CMoboJson::NewL()
	{
	CMoboJson* self = CMoboJson::NewLC();
	CleanupStack::Pop(self);
	return self;
	}

CMoboJson::CMoboJson()
// note, CBase initialises all member variables to zero
	{
	}

void CMoboJson::ConstructL()
	{
	// second phase constructor, anything that may leave must be constructed here
	iString = new (ELeave) TMoboJsonExampleString;
	}

EXPORT_C CMoboJson::~CMoboJson()
	{
	delete iString;
	}

EXPORT_C TVersion CMoboJson::Version() const
	{
	// Version number of example API
	const TInt KMajor = 1;
	const TInt KMinor = 0;
	const TInt KBuild = 1;
	return TVersion(KMajor, KMinor, KBuild);
	}

EXPORT_C void CMoboJson::ExampleFuncAddCharL(const TChar& aChar)
	{
	__ASSERT_ALWAYS(iString != NULL, Panic(EMoboJsonNullPointer));

	if (iString->Length() >= KMoboJsonBufferLength)
		{
		User::Leave(KErrTooBig);
		}

	iString->Append(aChar);
	}

EXPORT_C void CMoboJson::ExampleFuncRemoveLast()
	{
	__ASSERT_ALWAYS(iString != NULL, Panic(EMoboJsonNullPointer));

	if (iString->Length() > 0)
		{
		iString->SetLength(iString->Length() - 1);
		}
	}

EXPORT_C const TPtrC CMoboJson::ExampleFuncString() const
	{
	__ASSERT_ALWAYS(iString != NULL, Panic(EMoboJsonNullPointer));
	return *iString;
	}

